/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlconvert.internalStructure;

import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author ash
 */
public class Group implements Member{
    
    private static Logger LOG = Logger.getLogger(Group.class);
    private String name;
    private List<Member> members;
    
    public boolean isGroup(){
        return true;
    }
    
    public String getName(){
        return name;
    }
    
    public static Group createGroup(String n){
        try{
            Verifications.verifyGroup(n);
        } catch (VerificationException ve){
            LOG.warn("Cannot create group [" + n + "]. " + ve.getMessage());
            return null;
        }
        
        return new Group(n);
    }
    
    private Group(String n){    
        name = n;
        
        if(LOG.isDebugEnabled()){
            LOG.debug("New group [" + name + "] created.");
        }
    }
    
    public void addMember(Member m){
        members.add(m);
        
        if (LOG.isDebugEnabled()){
            LOG.debug("New member added to group [" + name + "]: [" + m.getName() + "]");
        }
    }
    
    public int size(){
        return members.size();
    }
    
    public Member member(int i){
        return members.get(i);
    }
    
    public static void main(String[] v){
        Group g = createGroup("blah");
        if (g != null){
        }
    }
    
    
}
